<template>
  <div>
    <el v-loading.fullscreen.lock="fullscreenLoading"></el>
  </div>
</template>

<script>
import { deleteJSON, getData, logout, postJSON } from "@/utils/http";
import { getLogsMap } from "@/utils/attr-map";
import { URL_MAP } from "@/config/config";
import { mapGetters } from "vuex";
import RecordSelect from '../utils/RecordSelect.vue';
import ReportSelect from '../utils/ReportSelect.vue';
export default {
  components: { RecordSelect, ReportSelect },
  data() {
    return {
      fullscreenLoading: true,
      dialogVisible: false,
      reportVisible: false,
      columns: [],
      selectedReport:'',
      data: [],
      recordVisible: false,
      pager: {
        pageSize: 10,
        current: 1,
      },
      pvalue: {
        name: "",
        date_gt: "",
        date_lt: "",
      },
      searchShow: true,
      params: {},
      paramKey: "sh-log-table-session",
    };
  },
  computed: {
    ...mapGetters([
      "userid",
      "token",
      "isProject",
      "isLogin",
      "username",
    ]),
  },

  methods: {
    onReport(obj) {
      this.$store.commit('projectName', obj.name)
      this.reportVisible  = true;
    },
    init() {
      let columns = getLogsMap();
      columns.push({
        key: "action",
        scopedSlots: { customRender: "action" },
      });
      this.columns = columns;
      this.params = {
        pageSize: this.pager.pageSize,
        currentPage: this.pager.current - 1,
      };
      // console.log(this.pager)
      this.fetch();
    },
    async fetch() {
      this.loadding = true;
      try {
        let data = await getData(URL_MAP.PROJECT_LIST, this.params);
        console.log(data);
        data = data.data;
        const pager = { ...this.pager };
        pager.total = data.totalCount;
        // pager.current = data.current
        pager.pageSize = data.pageSize;
        this.pager = pager;
        this.data = data.data.map(v => {
          v.date = new Date(v.date).toLocaleString()
          return v
        });
        this.onPre(this.data[0])
      } catch (e) {
        console.log(e);
      } finally {
        this.loadding = false;
      }
    },
    onPre(obj) {
      this.$store.commit("projectName", obj.name);
      // this.$store.commit("cache", { key: "review-state", value: true });
      this.$router.push({
        path: "/detail", 
      });
    },
  },
  mounted() {
    this.init();
  },
};
</script>

<style>
.title {
  position: absolute;
  left: calc(50% - 96px);
  text-align: center;
  margin-left: 24px;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
}
.w-title {
  color: #fff;
  font-size: 24px;
  font-weight: 600;
}
#reviews-layout .go-back-logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
  line-height: 32px;
  color: aliceblue;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  cursor: pointer;
}
</style>